local skill = fk.CreateSkill {
  name = "lvshi__unexpectation_skill",
}
local ls = require "packages/lvshi/utility"
skill:addEffect("cardskill", {
  prompt = "#lvshi__unexpectation_skill",
  target_num = 1,
  mod_target_filter = function(self, player, to_select, selected, card)
    return to_select ~= player and not to_select:isKongcheng()
  end,
  target_filter = Util.CardTargetFilter,
  on_use = function(self, room, use)
    local choice = ls.strategytrickuse(use.from, use.card, "unexpectation_scheme", "unexpectation_courage")
    use.extra_data = use.extra_data or {}
    use.extra_data.strategy = choice
  end,
  on_effect = function(self, room, effect)
    local player = effect.from
    local target = effect.to
    if target:isKongcheng() then return end
    local cards
    if effect.extra_data.strategy == "unexpectation_scheme" then
      cards = target:getCardIds("h")
    else
      local card = room:askToChooseCard(player, {
        target = target,
        flag = "h",
        skill_name = skill.name,
      })
      cards = {card}
    end
    target:showCards(cards)
    if target.dead then return end
    if table.find(cards, function (id) return Fk:getCardById(id):compareSuitWith(effect.card, true) end) then
      room:damage{
        from = player,
        to = target,
        card = effect.card,
        damage = 1,
        skillName = skill.name,
      }
    elseif effect.extra_data.strategy == "unexpectation_courage" then
      room:throwCard(cards, skill.name, effect.to, effect.to)
    end
  end,
})

return skill
